package org.rcy.ruicingmarket.interceptor;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author RuicyWu
 * @Date 2022/3/12 21:55
 */
public class RequestFromGateWayInterceptor implements HandlerInterceptor {
    protected final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String webToken = request.getHeader("webToken");
        if(StringUtils.isNotBlank(webToken)){
            return true;
        }

        logger.warn("Invalid request");
        return false;
    }
}
